package com.binhthuan.catechist.client.form;

import com.binhthuan.catechist.client.ECApplication;
import com.binhthuan.catechist.client.data.StatusDS;
import com.binhthuan.catechist.shared.constant.Parameter;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.form.fields.ButtonItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.TextItem;

public class StatusForm extends AbstractForm {

    public StatusForm() {
        super();
    }

    public StatusForm(StatusDS dataSource) {
        super(dataSource);
    }

    /**
     * 
     */
    private void initForm() {
        setMargin(10);
        setCellPadding(5);

        HiddenItem idField = new HiddenItem(Parameter.ID);

        TextItem nameField = new TextItem(Parameter.NAME);
        nameField.setTitle(ECApplication.getConstants().name());
        nameField.setRequired(true);
        nameField.setWidth(250);

        ButtonItem saveButton = createSaveButton();

        setFields(idField, nameField, saveButton);
    }

    /* (non-Javadoc)
     * @see com.smartgwt.client.widgets.form.DynamicForm#setDataSource(com.smartgwt.client.data.DataSource)
     */
    @Override
    public void setDataSource(DataSource dataSource) {
        super.setDataSource(dataSource);
        initForm();
    }
}
